package com.example.base.http

import com.example.base.entity.LoginEntity
import com.example.base.entity.NoticeEntity
import com.example.base.entity.ParkEntity
import com.example.base.entity.ParkEntityItem
import com.example.base.entity.RepairBean
import com.example.base.entity.RepairBeanItem
import com.example.base.entity.ReqEntity
import com.example.base.entity.Res
import com.example.base.entity.SignBean
import com.example.base.entity.VisitBean
import com.example.base.entity.VisitBeanItem
import com.example.base.entity.WxEntity
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query


interface ApiServer {
    //公告列表
    @GET("/api/announcements")
    fun getNotices(@Query("page") page : Int, @Query("size")size : Int): Flow<Res<NoticeEntity>>

    //注册
    @POST("/api/user/register")
    fun Req(@Query("password")password:String, @Query("username")username:String):Flow<Res<ReqEntity>>

    //登录
    @POST("/api/user/login")
    fun login(@Query("password")password:String, @Query("username")username:String):Flow<Res<LoginEntity>>

    //车位
    @GET("/api/parking-spaces/type/{spaceType}")
    fun  getParkByType(@Path("spaceType")spaceType:String):Flow<Res<ParkEntity>>

    @GET("/api/parking-spaces/area/{areaId}")
    fun  getParkByArea(@Path("areaId")areaId:Int):Flow<Res<ParkEntity>>

    @GET("/api/parking-spaces/status/{spaceStatus}")
    fun getParkByStatus(@Path("spaceStatus")spaceStatus:String):Flow<Res<ParkEntity>>

    @GET("/api/parking-spaces/license/{licensePlate}")
    fun getParkByCarNo(@Path("licensePlate")licensePlate:String):Flow<Res<ParkEntityItem>>

    @DELETE("/api/parking-spaces/{id}")
    fun deletePark(@Path("id")id:Int):Flow<Res<Boolean>>

    @GET("/api/parking-spaces/user/{userId}")
    fun queryById(@Path("userId")userId:Int):Flow<Res<ParkEntityItem>>

    @POST("/api/parking-spaces")
    fun addPark(@Body body: RequestBody):Flow<Res<ParkEntityItem>>

    @GET("/api/parking-spaces/{id}")
    fun getParkById(@Path("id")id:Int):Flow<Res<ParkEntityItem>>

    @PUT("/api/parking-spaces/{id}")
    fun updatePark(@Path("id")id:Int,@Body body: RequestBody):Flow<Res<ParkEntityItem>>

    //维修
    @GET("/api/repair-orders")
    fun getRepairs():Flow<Res<RepairBean>>

    @GET("/api/repair-orders/order-number/{orderNumber}")
    fun getRepairByNum(@Path("orderNumber")orderNumber:String):Flow<Res<RepairBeanItem>>

    @GET("/api/repair-orders/search")
    fun getRepairByUser(@Query("repairName")repairName:String):Flow<Res<RepairBean>>

    @POST("/api/repair-orders")
    fun addRepair(@Body body: RequestBody):Flow<Res<RepairBeanItem>>

    @DELETE("/api/repair-orders/{id}")
    fun deleteRepair(@Path("id")id:Int):Flow<Res<Boolean>>

    @GET("/api/repair-orders/{id}")
    fun getRepairById(@Path("id")id:Int):Flow<Res<RepairBeanItem>>

    @PUT("/api/repair-orders/{id}")
    fun updateRepair(@Path("id")id:Int,@Body body: RequestBody):Flow<Res<RepairBeanItem>>

    //来访
    @GET("/api/visit-appointments")
    fun getVisits():Flow<Res<VisitBean>>

    @GET("/api/visit-appointments/status/{status}")
    fun getVisitByStatus(@Path("status")status:String):Flow<Res<VisitBean>>


    @GET("/api/visit-appointments/search/name")
    fun getVisitByName(@Query("name")name:String):Flow<Res<VisitBean>>

    @GET("/api/visit-appointments/search/purpose")
    fun getVisitByPurpose(@Query("purpose")purpose:String):Flow<Res<VisitBean>>
    @POST("/api/visit-appointments")
    fun addVisit(@Body body: RequestBody):Flow<Res<VisitBeanItem>>

    @DELETE("/api/visit-appointments/{id}")
    fun deleteVisit(@Path("id")id:Int):Flow<Res<Boolean>>

    @GET("/api/visit-appointments/{id}")
    fun getVisitById(@Path("id")id:Int):Flow<Res<VisitBeanItem>>

    @PATCH("/api/visit-appointments/approve/{id}")
    fun approveVisit(@Path("id")id:Int):Flow<Res<VisitBeanItem>>

    @PATCH("/api/visit-appointments/reject/{id}")
    fun rejectVisit(@Path("id")id:Int):Flow<Res<VisitBeanItem>>

    @GET("/api/attendances/user/{userId}")
    fun getSigns(@Path("userId")userId:Int):Flow<Res<SignBean>>
}